package cn.schoolwow.quickdao.test.module.business.user.dml.json.flow.compare;

import cn.schoolwow.quickdao.domain.DAO;
import cn.schoolwow.quickdao.domain.database.dml.CompareJSONArrayResult;
import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;
import com.alibaba.fastjson.JSONArray;
import org.junit.Assert;

public class CheckCompareJSONArrayResultFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        DAO dao = flowContext.checkInstanceData(DAO.class);
        JSONArray compareUserList = (JSONArray) flowContext.checkData("compareUserList");

        CompareJSONArrayResult compareJSONArrayResult = dao.uniqueFieldNames("username", "password").compareJSONArray("user", compareUserList);

        Assert.assertEquals(10, compareJSONArrayResult.insertJSONArray.size());
        Assert.assertEquals(11, compareJSONArrayResult.updateJSONArray.size());
    }

    @Override
    public String name() {
        return "设置待比较的用户JSON数组";
    }
}
